

 

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
$sql_query = "select * from school  where NOT EXISTS (SELECT * from player where play_scho_id=scho_senc_id) order by scho_name asc ";
cast(grn_date as date)
//===================================================================
SELECT grn_numb,grn_date,grn_netv,supp_id,supp_name,paym_id,paym_date
FROM grn 
LEFT JOIN supplier ON grn.grn_supp_id = supplier.supp_id
LEFT JOIN supplier_payment ON grn.grn_numb = supplier_payment.paym_grn_id and supplier.supp_id = supplier_payment.paym_supp_id and supplier_payment.paym_stat != 'del' 
WHERE grn_date between '$dFrom' and '$dTo' ";
//--------------------------------------------------------------------
//receipt.rece_date between '$date_from' and '$date_to'
//--------------------------------
SELECT 
  TBL1.AMOUNT T1,  
  TBL2.AMOUNT T2,  
  TBL3.AMOUNT T3
FROM TBL1
LEFT JOIN TBL2 ON TBL2.ID = TBL1.ID
LEFT JOIN TBL3 ON TBL3.ID = TBL1.ID
//--------------------------------------------------------
SELECT column_name(s)
FROM table1
LEFT JOIN table2 ON table1.column_name = table2.column_name;

//-----------------------------------------------------------------------
SELECT DISTINCT store_type FROM stores
  WHERE EXISTS (SELECT * FROM cities_stores
                WHERE cities_stores.store_type = stores.store_type);

SELECT EXISTS (SELECT * FROM absence);
SELECT NOT EXISTS (SELECT * FROM absence);

//-----------------------------------------
SELECT expressions
FROM tables
[WHERE conditions]
ORDER BY column-name [ ASC | DESC ];
//------------------------------------------

//-----------------Remove Duplicates in a array ------------------------
//$ba = array_unique($aa, SORT_REGULAR);// remove duplicates in a array aa
//--------------------------------------------------------------------------
//cheq_rece_date between '$date_from' and '$date_to'

//===========================================================================
//---------------------------Upper case ------------------------------------
oninput="this.value = this.value.toUpperCase()

//---------------------------- select text field ---------------------------
onfocus="this.select()" onmouseup="return false" 

//------------------------Rotate Text --------------------------------------

 // <th style="width:35px;height:100px;padding-left:2px;padding-right:2px;padding-top:2px;padding-bottom:3px;margin-top:0;margin-bottom:3px;"><p style="transform: rotate(-90deg);"> 100M </P></th

 //----------------------select menu default value---------------------------
$('#id_sex').parent().parent().parent().parent().parent().find('.cl_sex').val("");

//-----------------------close window -------------------------------
 onclick="javascript:window.close();opener.window.focus();" 

//------------------------------------------------------------------

function get_cheque(v){// get cheques of selected customer
$(v).parent().parent().parent().parent().parent().find('.chqAmt').empty() //clear option id_r_id
var re_id = $('#id_r_id').parent().parent().parent().parent().parent().find('.cl_r_id').val()
$(v).parent().parent().parent().parent().parent().find('.chqAmt').append('<option value="0">--Select Cheque--</option>') // set first option
 // set first option
c_id=$(v).val();  //get current customer id into variable
	$.get("aj.php?cid="+c_id+"&rid="+re_id+"&frm=getCusChq",function(myjson){ // send values to aj.php through JSON url
		var jd=JSON.parse(myjson);//receive the result from "aj.php" file and asign in to "jd" variable
		for(var i=0;i<jd.length;i++){ // using for loop append values to select menu.
			var cid=jd[i].chq_id;
			var cno=jd[i].chq_numb; // 
			var amt=jd[i].chq_amou; //
			
			$(v).parent().parent().parent().parent().parent().find('.chqAmt').append('<option value="'+cid+'">'+cid+' - '+cno+' ---> '+amt+'</option>');
		}
	}); 
}


//==============================================================
----------------stop mouse down event-----------------
onmousedown="(function(e){ e.preventDefault(); })(event, this)"
//==============================================================
//----------stop enter key -----------------
onkeydown='return (event.keyCode!=13);'
//==========================================

if (isset($_POST['n_cust'])) {
$R_data=$_POST['n_cust'];
$cusId = explode("|",$R_data)[0];
$cusName = explode("|",$R_data)[1];
echo $cusId;
echo $cusName;
}else
{$cusId = 0; $cusName = "";}
................
echo "<option value='$sh_item->sho_id|$sh_item->sho_name' selected> ".$sh_item->sho_name.' - ('.$sh_item->sho_id.')'."</option>";

//------------------------------------------
number_format($tot,2) // php Number format

//*****************************************
tooltip colors
(protip.min.css)
arrow #00aeff
background ccefff
//*******************************************

function chkName(sid){
var txtBox=document.getElementById(sid).value;
var validate_name = /[^a-zA-Z\-]/;
if (validate_name.test( txtBox )){	
	$(".VName").notify("Invalied name",{position:"right"});
	}
}

//----------------------------------------------------------------------
function AllowAlphabet(evt) {
 var charCode = (evt.which) ? evt.which : event.keyCode;
 if ((charCode > 64 && charCode < 91) || (charCode > 96 && charCode < 123))
 return true;
 else
return false;
}
//------------------------------------------
<input class="usr" type="text id="whatever" name="whatever" />

        $(".usr").keyup(function() {
            var n = $(this).val();
            if ( n.match("^[a-zA-Z0-9 ]*$") == null ) {
                $(this).val(n.slice(0,-1));
            }
        });
//-------------------------------------------
function phonenumber(inputtxt)
{
  var phoneno = /^\d{10}$/;
  if((inputtxt.value.match(phoneno))
        {
      return true;
        }
      else
        {
        alert("message");
        return false;
        }
}
//----------------------------------------------
function stringlength(inputtxt, minlength, maxlength)
{ 
var field = inputtxt.value; 
var mnlen = minlength;
var mxlen = maxlength;

if(field.length<mnlen || field.length> mxlen)
{ 
alert("Please input the userid between " +mnlen+ " and " +mxlen+ " characters");
return false;
}
else
{ 
alert('Your userid have accepted.');
return true;
}
}
//--------------------------------------
function allnumeric(inputtxt)
   {
      var numbers = /^[0-9]+$/;
      if(inputtxt.value.match(numbers))
      {
      alert('Your Registration number has accepted....');
      document.form1.text1.focus();
      return true;
      }
      else
      {
      alert('Please input numeric characters only');
      document.form1.text1.focus();
      return false;
      }
   } 
//------------------------------------
function allLetter(inputtxt)
  {
   var letters = /^[A-Za-z]+$/;
   if(inputtxt.value.match(letters))
     {
      return true;
     }
   else
     {
     alert("message");
     return false;
     }
  }
//-----------------------------------
function alphanumeric(inputtxt)
{ 
var letters = /^[0-9a-zA-Z]+$/;
if(inputtxt.value.match(letters))
{
alert('Your registration number have accepted : you can try another');
document.form1.text1.focus();
return true;
}
else
{
alert('Please input alphanumeric characters only');
return false;
}
}
//-------------------------------------
function alphanumeric(inputtxt)
{
 var letterNumber = /^[0-9a-zA-Z]+$/;
 if((inputtxt.value.match(letterNumber)) 
  {
   return true;
  }
else
  { 
   alert("message"); 
   return false; 
  }
  }
//--------------------------------
pattern="[A-Za-z]{3}"

//$(v).focus();

	if(qty>avQty){
	//----------------------------------
	var msg = "No such a stock amount !!!!";
	var type = "errmsg"; //infoMsg or errmsg
	ErrorMsg(msg,type); 
	$(v).css('border-color','red');
	//---------------------------------
	}else{
		$(v).css('border-color','#cccccc');
		calTotBeforeDiscount(v);
		cal();
	}
	//----------------------------------------------
function ErrorMsg(msg,type){
msgHtml = "<span class='"+type+"'><i class='glyphicon glyphicon-info-sign'></i>&nbsp&nbsp '"+msg+"' </span>"; 

 $('#errMsg').parent().find('#errMsg').html(msgHtml);
 $(document).ready(function (){
	setTimeout(function(){
	 $('#errMsg').parent().find('#errMsg').html(""); }, 5000);
  });
}
//============================================================================
function get_chq_amount($chq_id){
$sql_query= "select cheq_amou from cheque where cheq_id = '$chq_id'";
	$ref=$this->db->query($sql_query);
	$amt=0;
	while ($row=$ref->fetch_array()){ // get all saved login to array from the table
	$ch = new cheque_class();
		$amt=$row['cheq_amou'];
			}
	return trim($amt);// return array with data
}
//------------------------------------------------------------
if ($ref->num_rows > 0) {
}else{return 0;}
if ($list != 0) {
//--------------------- record count check  ------------------
$ref = $this->db->query($sql_query);

if ($ref->num_rows > 0) {
while ($row=$ref->fetch_array()){
		$re=new receipt_class();
		$re->rec_date = $row['rece_date'];		
		$re->rec_id=$row['rece_id'];

		$re->rec_desc = $row['rece_desc'];

		$arr[]=$re;
		}
return $arr;
}else{return 0;}
//-------------------------------
 $list=$che->get_all_cheque();
if ($list != 0) {
	foreach($list as $item){
	?>
	<tr>
			<td class='chqId'><?php echo $item->chq_id?> </td>
			<td class='chqCustName'><?php echo $item->chq_cust_name?> </td>
			<td class='chqBank'><?php echo $item->chq_bank?> </td>
			<td class='chqDesc'><?php echo $item->chq_desc?> </td>
			<td class='chqStat'><?php echo $item->chq_stat?> </td> 
			<td><input type="checkbox" name="chk[]" value="<?php echo $item->chq_id;?>"> </td> 
   </tr> 
   		<?php
         	}
         	}// end of if	

//--------------------- jquery function call from php ------------------
if ($item->rec_type=="Cheque"){
?>	
<script> 
	$(document).ready(function(){
	pmtMtd_select('#id_pmtMtd');	
	})
</script>
<?php
//----------------------
<?php
if( some condition ){
    echo "<script>alert('Hello World');</script>";
}
?>



-----------------------get total with in loop-----------------------------------

$supplier_id = $_SESSION["SUPPLIER_ID"];
$sql_query= "select * from cus_invoice where invo_stat!='del' and invo_shop_id='$cus_id' and invo_supp_id='$supplier_id'";
$ref = $this->db->query($sql_query);
while ($row=$ref->fetch_array()){
		$in=new invoice_class();
		$in->inv_date = $row['invo_date'];		
		$in->inv_netv= $row['invo_netv'];
		$in->inv_numb=$row['Invo_numb'];	
//------------------------------------------------
$sql_quary2 = "SELECT SUM(real_paid_amou) as invTotPaid  FROM receipt_allocation where real_comp_id='$supplier_id' AND real_invo_id='".$row['Invo_numb']."'";
	$Tot =  $this->db->query($sql_quary2);
	while ($row=$Tot->fetch_array()){
	//$invPaidAmt = 
	$in->inv_paid_val = $row['invTotPaid'];
	}
//------------------------------------------------
		$arr[]=$in;
		}
		//print_r($arr);
		return $arr;

}
----------check aj.php-------------------------------------------------------------

http://localhost/tharindu_dms/aj.php?ite_id=4&frm=get_vs_batc

-----------------------------------------------------------------------
function shop_name(){
var sh_na=document.getElementById('s_name').value;
}
-----------------------------------------------------------------------
if (sh_na===""){
alert ('data required');
 return false;
 }
------------------------------------------------------------------------
if (sh_na.length > 10 or s_address > 20){
               alert ('Length is too much');
               return false;
               
           }else
           {
             return true; 
           }
------------------------------------------------------------------------
	$("#nic").blur(function(){
		txt=$("#nic").val();
		//if(txt.length >1){ //chk for min length
			
			//ajax req..
			$.get("/bitplus009/ajax/nic.php","nic="+txt,function(data){
				//alert(data);	
				if(data=="found"){   // IF AN EXISTING NIC NO
					$("#snic2").html("NIC allready in use !!!");
					$("#nic").addClass("er");
				}
				else
					$("#nic").removeClass("er");
					$("#snic").html("");
			});
		//}
	});
------------------------------------------------------------------------
	$("#bnq").click(function(){
		tmp = $("#or").html();
		$("#spn").append(tmp);
	});
------------------------------------------------------------------------
	function del(x){
		$(x).parent().parent().remove();
	};

------------------------------------------------------------------------
$("#dd1").change(function(){
	

	
	if($("#dd1").val()=="4")
		$("#cbd").show(200);
	else
		$("#cbd").hide(200);
	
	
});

------------------------------------------------------------------------

$("#r1").change(function(){
	$("#ol").hide(300,function(){$("#al").show(300);});
	
});

------------------------------------------------------------------------
$("#r2").change(function(){
	$("#ol").show(600);
	$("#al").hide(600);
});
------------------------------------------------------------------------
	$("#dcat").change(function (){
		$.get("ajax_sc.php","c="+$("#dcat").val(),function(data){
			
			alert(data);
			$("#dsc").html(data);
			//allsc = JSON.parse(data);
//			for(tmp in allsc){
//				
//				alert(tmp[2]);
//			}
			//alert(allsc[0].sc_code);
			
		});						
	});
------------------------------------------------------------------------
		function fdel(val){
			//alert("hi");
			if(confirm("Are you sure to delete ?")){
				
				$.get("ajax2.php","id="+val,function(data){
					//alert(data);
					
					
					//$("#r"+val).hide(500);
					$("#r"+val).addClass("del");
				
				});
				//window.location='list.php?id='+val;
			}
		}
------------------------------------------------------------------------
	$("#b1").click(function (){
			//	alert(	$("#f1").serialize());		 
							 
		$.post("ajax_1.php", $("#f1").serialize() , 
			function(data){
				//alert(data);
				if(data=="ok"){
					$("#d1").show(2000,hide(500));
					$("#f1")[0].reset();	
				}
				
			} );						 
		});
	
-----------------------------------------------------------------------
  $(function () {
    $('input').iCheck({
      checkboxClass: 'icheckbox_square-blue',
      radioClass: 'iradio_square-blue',
      increaseArea: '20%' // optional
    });
  });
--------------------------------------------------------------------------------------------------
/*	$.get("aj.php?id="+val+"&frm=maxbatch",function(mbjson){
		// id,frm are parameter names & val , maxbatch are values
		var jd= JSON.parse(mbjson);
		alert(jd);
		for (var i=0;i<mbjson.length;i++){
			var res=mbjson[i];
			alert (i,res);
		}
	});	*/
/----------------------------------------------------------
        /*for(var i=0;i<myjson.length;i++){
			var res = myjson[i];
			//res++;
			//alert(res);
			document.getElementById("result_batch").value=res;
		    }
			//alert('aa');
		}*/
/------------------------------------------------------------------------------
<table id="table_header">
<tr>
   <td contenteditable="true">a</td>
   <td contenteditable="true">b</td>
   <td contenteditable="true">c</td>
</tr>
</table

/--------------------------------------------------------------------------------
function selectText(){	//Select all text in the text box.
$(id).focus(function () { 
            $(id).select();
        });
}
/----------------------------------------------------------------

if(!isNaN(this.value) && this.value.length!=0) 
/----------------------------------------------------------------
<?php echo number_format("$item->rec_amount",2) ?>